#include<bits/stdc++.h>
#define rep(l,r,i) for(int i=l;i<=r;i++) 
#define per(l,r,i) for(int i=l;i>=r;i--) 
#define pi pair<int,int> 
#define mk make_pair 
using namespace std;
#define int long long 
#define Maxn 5005 
int plen,ptop,pstk[40];
char rdc[1<<20],out[1<<20],*rS,*rT;
#define gc() (rS==rT?rT=(rS=rdc)+fread(rdc,1,1<<20,stdin),(rS==rT?EOF:*rS++):*rS++)
#define pc(x) out[plen++]=(x)
#define flush() fwrite(out,1,plen,stdout),plen=0
template<class T>inline void read(T &x){
    x=0;char ch;bool f=1;
    while(!isdigit(ch=gc()))if(ch=='-')f^=1;
    do x=(x<<1)+(x<<3)+(ch^48);while(isdigit(ch=gc()));
	if(!f)x=-x;
}
template<class T=int>inline void write(T x){
	if(plen>=1000000)flush();
	if(!x)return pc('0'),void();
	if(x<0)pc('-'),x=-x;
	for(;x;x/=10)pstk[++ptop]=x%10;
	while(ptop)pc(pstk[ptop--]+'0');
}
int n,k,a[Maxn],b[Maxn],sum[Maxn],R[Maxn],f[2505][Maxn],maxn[Maxn];
int calc(int l,int r) {
    return sum[r]-sum[l-1];
}
void Main() {
    cin>>n>>k;
    // read(n); read(k);
    rep(0,n+1,i)rep(0,Maxn-1,j)f[i][j] = 0;
    rep(0,Maxn-1,i)maxn[i] = 0;
    rep(1,n-1,i)cin>>a[i]; a[0] = a[n] = Maxn-1;
    rep(1,k,i)cin>>b[i],sum[i] = sum[i-1]+b[i];
    rep(1,n,i)R[i] = calc(max(1ll,k-n+i),min(k,i));
    rep(1,n,i) {
        rep(0,min(a[i-1],a[i]),j)
            f[i][j] = (a[i-1]-j >= 0?maxn[a[i-1]-j]:0)+j*R[i];
        rep(0,Maxn-1,j)maxn[j] = max((j > 0?maxn[j-1]:0),f[i][j]);
    } 
    cout<<maxn[a[n-1]]<<"\n";
    // write(f[n][a[n-1]]); pc('\n');
    return void();
}
signed main()
{
    freopen("festival3.in","r",stdin);
    freopen("festival.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int c,t; 
    cin>>c>>t;
    // read(c); read(t);
    while(t --)Main();
    // flush();
    return 0;
}